<html>
<head id="foo">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div></div>
<img name="location">
<script>
test(function() {
  window.abcd = 15;
  assert_equals(window.abcd, 15);
  assert_equals(Object.getOwnPropertyDescriptor(window, 'abcd').value, 15);
  assert_equals(window.hasOwnProperty('abcd'), true);

  assert_equals('location' in window, true);

  // Can't set indexed properties
  window[100] = "abc";
  assert_equals(window[100], undefined);
  assert_equals(Object.getOwnPropertyDescriptor(window, 1000), undefined);
});

test(function() {
  assert_own_property(window, 'location')
}, "Unforgeable location");

test(function() {
  document.foo
  assert_equals(document.location, window.location,
                'The <img name="location"> should not override the location getter');
}, "document.location is the right thing");

test(function() {
  var doc = new DOMParser().parseFromString("<img name='location'>", "text/html");
  assert_equals(doc.location, null,
                'The <img name="location"> should not override the location getter on a data document');
}, "document.location is the right thing on non-rendered document");
</script>
</body>
</html>
